package com.ruoyi.chengji.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.pingjiao.domain.CourseclassMetaclass;
import com.ruoyi.pingjiao.service.ICourseclassMetaclassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 行政班级上课Controller
 * 
 * @author 牛亚博
 * @date 2023-07-10
 */
@RestController
@RequestMapping("/score/CourseclassMetaclass")
public class CourseclassMetaclassController extends BaseController
{
    @Autowired
    private ICourseclassMetaclassService courseclassMetaclassService;

    /**
     * 查询行政班级上课列表
     */
    @PreAuthorize("@ss.hasPermi('score:courseclassMetaclass:list')")
    @GetMapping("/list")
    public TableDataInfo list(CourseclassMetaclass courseclassMetaclass)
    {
        startPage();
        List<CourseclassMetaclass> list = courseclassMetaclassService.selectCourseclassMetaclassList(courseclassMetaclass);
        return getDataTable(list);
    }

    /**
     * 导出行政班级上课列表
     */
    @PreAuthorize("@ss.hasPermi('score:courseclassMetaclass:export')")
    @Log(title = "行政班级上课", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CourseclassMetaclass courseclassMetaclass)
    {
        List<CourseclassMetaclass> list = courseclassMetaclassService.selectCourseclassMetaclassList(courseclassMetaclass);
        ExcelUtil<CourseclassMetaclass> util = new ExcelUtil<CourseclassMetaclass>(CourseclassMetaclass.class);
        util.exportExcel(response, list, "行政班级上课数据");
    }

    /**
     * 获取行政班级上课详细信息
     */
    @PreAuthorize("@ss.hasPermi('score:courseclassMetaclass:query')")
    @GetMapping(value = "/{courseclassId}")
    public AjaxResult getInfo(@PathVariable("courseclassId") Long courseclassId)
    {
        return AjaxResult.success(courseclassMetaclassService.selectCourseclassMetaclassByCourseclassId(courseclassId));
    }

    /**
     * 新增行政班级上课
     */
    @PreAuthorize("@ss.hasPermi('score:courseclassMetaclass:add')")
    @Log(title = "行政班级上课", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CourseclassMetaclass courseclassMetaclass)
    {
        System.out.println("courseclassMetaclass = " + courseclassMetaclass);
        return toAjax(courseclassMetaclassService.insertCourseclassMetaclass(courseclassMetaclass));
    }

    /**
     * 修改行政班级上课
     */
    @PreAuthorize("@ss.hasPermi('score:courseclassMetaclass:edit')")
    @Log(title = "行政班级上课", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CourseclassMetaclass courseclassMetaclass)
    {
        System.out.println("courseclassMetaclass = " + courseclassMetaclass);
        return toAjax(courseclassMetaclassService.updateCourseclassMetaclass(courseclassMetaclass));
    }

    /**
     * 删除行政班级上课
     */
    @PreAuthorize("@ss.hasPermi('score:courseclassMetaclass:remove')")
    @Log(title = "行政班级上课", businessType = BusinessType.DELETE)
	@DeleteMapping("/{courseclassIds}")
    public AjaxResult remove(@PathVariable Long[] courseclassIds)
    {
        return toAjax(courseclassMetaclassService.deleteCourseclassMetaclassByCourseclassIds(courseclassIds));
    }

    /**
     * 删除行政班级上课
     */
    @PreAuthorize("@ss.hasPermi('score:courseclassMetaclass:remove')")
    @Log(title = "行政班级上课", businessType = BusinessType.DELETE)
    @PostMapping("/deleteId")
    public AjaxResult removeId(@RequestBody CourseclassMetaclass courseclassMetaclass)
    {
        return toAjax(courseclassMetaclassService.deleteCourseclassMetaclassByCourseclassId(courseclassMetaclass.getCourseclassId(),courseclassMetaclass.getMetaclassId()));
    }
}
